// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.


using NSQL.Expressions.Functions;

namespace NSQL.Expressions
{
    public abstract class AbstractExpressionVisitor : IExpressionVisitor
    {
        void IFunctionVisitor.Visit(ICountFunction countFunction) => VisitChildren(countFunction);

        void IFunctionVisitor.Visit(IRoundFunction roundFunction) => VisitChildren(roundFunction);

        void IFunctionVisitor.Visit(ISumFunction sumFunction) => VisitChildren(sumFunction);

        void IFunctionVisitor.Visit(IMaxFunction maxFunction) => VisitChildren(maxFunction);

        void IFunctionVisitor.Visit(IAvgFunction avgFunction) => VisitChildren(avgFunction);

        void IFunctionVisitor.Visit(IMinFunction minFunction) => VisitChildren(minFunction);
        void IFunctionVisitor.Visit(IMedianFunction expression) => VisitChildren(expression);

        void IFunctionVisitor.Visit(IStdDevFunction stdDevFunction) => VisitChildren(stdDevFunction);

        void IFunctionVisitor.Visit(IVarianceFunction varianceFunction) => VisitChildren(varianceFunction);

        void IFunctionVisitor.Visit(IToCharFunction toCharFunction) => VisitChildren(toCharFunction);

        void IFunctionVisitor.Visit(ITrimFunction trimFunction) => VisitChildren(trimFunction);

        void IFunctionVisitor.Visit(ILengthFunction lengthFunction) => VisitChildren(lengthFunction);
        void IFunctionVisitor.Visit(ICastFunction castFunction) => VisitChildren(castFunction);

        void IFunctionVisitor.Visit(IToNumberFunction toNumberFunction) => VisitChildren(toNumberFunction);

        void IFunctionVisitor.Visit(ISubStringFunction stringFunction) => VisitChildren(stringFunction);

        void IFunctionVisitor.Visit(INvlFunction nvlFunction) => VisitChildren(nvlFunction);
        void IFunctionVisitor.Visit(IPadFunction padFunction) => VisitChildren(padFunction);
        void IFunctionVisitor.Visit(ILeftFunction leftFunction) => VisitChildren(leftFunction);
        void IFunctionVisitor.Visit(IRightFunction rightFunction) => VisitChildren(rightFunction);

        void IFunctionVisitor.Visit(IUpperFunction upperFunction) => VisitChildren(upperFunction);

        void IFunctionVisitor.Visit(ILowerFunction lowerFunction) => VisitChildren(lowerFunction);

        void IFunctionVisitor.Visit(IReplaceFunction replaceFunction) => VisitChildren(replaceFunction);

        void IFunctionVisitor.Visit(IExtractFunction extractFunction) => VisitChildren(extractFunction);

        void IFunctionVisitor.Visit(IConcatFunction concatFunction) => VisitChildren(concatFunction);

        void IFunctionVisitor.Visit(IReverseFunction reverseFunction) => VisitChildren(reverseFunction);

        void IFunctionVisitor.Visit(IToDatetimeFunction toDatetimeFunction) => VisitChildren(toDatetimeFunction);

        void IFunctionVisitor.Visit(IAddIntervalFunction addIntervalFunction) => VisitChildren(addIntervalFunction);

        void IFunctionVisitor.Visit(IStartWithFunction startWithFunction) => VisitChildren(startWithFunction);

        void IFunctionVisitor.Visit(IEndWithFunction endWithFunction) => VisitChildren(endWithFunction);

        void IFunctionVisitor.Visit(IContainsFunction containsFunction) => VisitChildren(containsFunction);

        void IFunctionVisitor.Visit(ISinFunction sinFunction) => VisitChildren(sinFunction);

        void IFunctionVisitor.Visit(ICosFunction cosFunction) => VisitChildren(cosFunction);

        void IFunctionVisitor.Visit(ITanFunction tanFunction) => VisitChildren(tanFunction);

        void IFunctionVisitor.Visit(IAbsFunction absFunction) => VisitChildren(absFunction);
        void IFunctionVisitor.Visit(ISignFunction signFunction) => VisitChildren(signFunction);
        public void Visit(ISqrtFunction expression) => VisitChildren(expression);

        public void Visit(ILogFunction expression) => VisitChildren(expression);

        public void Visit(IPowFunction expression) => VisitChildren(expression);
        public void Visit(IRankFunction expression) => VisitChildren(expression);
        public void Visit(ICoalesceFunction expression) => VisitChildren(expression);

        public void Visit(IDecodeFunction expression) => VisitChildren(expression);
        public void Visit(ICeilFunction expression) => VisitChildren(expression);

        public void Visit(IFloorFunction expression) => VisitChildren(expression);

        public void Visit(IPercentileFunction expression) => VisitChildren(expression);
        public void Visit(IFormatFunction expression) => VisitChildren(expression);

        void IFunctionVisitor.Visit(IDiffFunction expression) => VisitChildren(expression);

        void IExpressionVisitor.Visit(IComparisonExpression comparisonExpression) =>
            VisitChildren(comparisonExpression);

        void IExpressionVisitor.Visit(IColumnExpression columnExpression) => VisitChildren(columnExpression);

        void IExpressionVisitor.Visit(IConstantExpression constantExpression) => VisitChildren(constantExpression);

        void IExpressionVisitor.Visit(IInExpression inExpression) => VisitChildren(inExpression);

        void IExpressionVisitor.Visit(INotInExpression notInExpression) => VisitChildren(notInExpression);

        void IExpressionVisitor.Visit(ILogicalExpression expression) => VisitChildren(expression);

        void IExpressionVisitor.Visit(IBetweenExpression betweenExpression) => VisitChildren(betweenExpression);

        void IExpressionVisitor.Visit(INotExpression notExpression) => VisitChildren(notExpression);

        void IExpressionVisitor.Visit(INullExpression nullExpression) => VisitChildren(nullExpression);

        void IExpressionVisitor.Visit(INotNullExpression notNullExpression) => VisitChildren(notNullExpression);

        void IExpressionVisitor.Visit(IMatchExpression matchExpression) => VisitChildren(matchExpression);

        void IExpressionVisitor.Visit(ISimpleMatchExpression simpleMatchExpression) =>
            VisitChildren(simpleMatchExpression);

        void IExpressionVisitor.Visit(IArithmeticExpression arithmeticExpression) =>
            VisitChildren(arithmeticExpression);

        void IExpressionVisitor.Visit(IUnaryExpression unaryExpression) => VisitChildren(unaryExpression);

        void IExpressionVisitor.Visit(ISystemVariable systemVariable) => VisitChildren(systemVariable);

        void IExpressionVisitor.Visit(ILikeExpression likeExpression) => VisitChildren(likeExpression);

        void IExpressionVisitor.Visit(IExpressions inElements) => VisitChildren(inElements);

        void IExpressionVisitor.Visit(IExistsExpression existsExpression) => VisitChildren(existsExpression);

        protected virtual void VisitChildren(IExpression expression)
        {
            foreach (var expression1 in expression.Accept(ChildrenVisitor))
            {
                expression1?.Accept(this);
            }
        }

        protected virtual ExpressionChildrenVisitor ChildrenVisitor { get; } = ExpressionChildrenVisitor.Instance;

        IFunctionVisitor IExpressionVisitor.FunctionVisitor => this;
    }
}